package project;
import java.util.Scanner;

public class Proofemail {
	public static void main(String[] args){
		System.out.println("请输入您的email地址");
		Scanner input=new Scanner(System.in);
		String email=input.next();
//将字符串转换为字符数组
		char[] newemail=email.toCharArray();
		int length=email.length();
/*		for(int i=0;i<length;i++){
			System.out.println(newemail[i]);
			}*/
		if(proof(newemail,length)){
			System.out.println("您输入的地址有效");
		}
		else{
			System.out.println("您输入的地址非法！");
		}
		}
	public static boolean proof(char[] newemail,int length){
		boolean judge=false;
		int first=-1;	int second=-1;
		for(int i=0;i<length;i++){
			if(newemail[i]=='@'){
				first=i;
			}
			if(newemail[i]=='.'){
				second=i;
			}
			if(first==-1||second==-1){
				judge=false;
			}
			if(first<second){
				judge=false;
			}
			if(first>second){
				if(first==0){
					judge=false;
				}
			}
			else if(first<second){
				if(first!=0){
					if(newemail[length-3]=='c'&&newemail[length-2]=='o'&&newemail[length-1]=='m'){
						judge=true;
					}
					else if(newemail[length-2]=='c'&&newemail[length-1]=='n'){
						judge=true;
					}
					else if(newemail[length-3]=='n'&&newemail[length-2]=='e'&&newemail[length-1]=='t'){
						judge=true;
					}
					else if(newemail[length-3]=='g'&&newemail[length-2]=='o'&&newemail[length-1]=='v'){
						judge=true;
					}
					else if(newemail[length-3]=='e'&&newemail[length-2]=='d'&&newemail[length-1]=='u'){
						judge=true;
					}
					else if(newemail[length-3]=='o'&&newemail[length-2]=='r'&&newemail[length-1]=='g'){
						judge=true;
					}

				}
			}
		}
		return judge;
	}
}
